﻿#ifndef FD_CORE_MULTIBYTESTRING_H
#define FD_CORE_MULTIBYTESTRING_H
#pragma once

#include <sstream>
#include <vector>
#include "kernel/Prerequisites_kernel.h"
#include "kernel/dll_cfg.h"

namespace FD
{
	namespace Kernel
	{
		typedef std::basic_string<WCHAR> wchar_string;
		class FdUnicodeString;
		class ITextCodec;
		class FdChar;
		class FdUtf8String;
		class FdGbkString;
		class FD_Kernel_Export FdMultiByteString
		{
			friend class FdUnicodeString;
			friend class FdUtf8String;
		public:
			enum CharSet
			{
				CS_LOCAL,
				CS_GBK,
				CS_UTF8
			};
		public:
			typedef std::string::const_iterator const_iterator;
			typedef std::string::iterator iterator;
			typedef std::string::const_reverse_iterator const_reverse_iterator;
			typedef std::string::reverse_iterator reverse_iterator;
			typedef std::string::value_type value_type;
			typedef std::string::size_type size_type;

			FdMultiByteString& replace(iterator begin, iterator end, const std::string &str)
			{
				m_strDataBuffer.replace(begin, end, str);
				return *this;
			}

			FdMultiByteString& replace(const_iterator begin, const_iterator end, const std::string &str)
			{
				m_strDataBuffer.replace(begin, end, str);
				return *this;
			}

			FdMultiByteString& replace(size_type _Off, size_type _N0, const std::string& _Right, size_type _Roff = 0, size_type _Count = npos)
			{
				m_strDataBuffer.replace(_Off, _N0, _Right, _Roff, _Count);
				return *this;
			}
			/// <summary>
			/// 返回字符串首字符的迭代器
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			const_iterator begin() const
			{
				return m_strDataBuffer.begin();
			}
			iterator begin()
			{
				return m_strDataBuffer.begin();
			}
			/// <summary>
			/// 返回字符串尾字符的迭代器
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			const_iterator end() const
			{
				return m_strDataBuffer.end();
			}
			iterator end()
			{
				return m_strDataBuffer.end();
			}

			const_reverse_iterator rbegin() const
			{
				return m_strDataBuffer.rbegin();
			}

			reverse_iterator rbegin()
			{
				return m_strDataBuffer.rbegin();
			}

			const_reverse_iterator rend() const
			{
				return m_strDataBuffer.rend();
			}

			reverse_iterator rend()
			{
				return m_strDataBuffer.rend();
			}

			int compare(size_type _Off,
				size_type _N0, const std::string& _Right,
				size_type _Roff = 0, size_type _Count = std::string::npos) const
			{
				return m_strDataBuffer.compare(_Off, _N0, _Right, _Roff, _Count);
			}

			int compare(const std::string& _Right) const
			{
				return m_strDataBuffer.compare(_Right);
			}

			/// <summary>
			/// 从字符串指定位置中擦除字符
			/// </summary>
			/// <param name="pos">开始擦除的位置</param>
			/// <param name="count">要擦除字符的个数</param>
			/// <param name="first">开始擦除的位置</param>
			/// <param name="last">结束擦除的位置</param>
			/// <returns>擦除后的字符串或者迭代器</returns>
			FdMultiByteString &erase(size_t pos = 0, size_t count = npos)
			{
				m_strDataBuffer.erase(pos, count);
				return *this;
			}
			iterator erase(iterator pos)
			{
				iterator iter = m_strDataBuffer.erase(pos);
				return iter;
			}
			iterator erase(iterator first, iterator last)
			{
				iterator iter = m_strDataBuffer.erase(first, last);
				return iter;
			}
		public:
			static size_t npos;

			/// <summary>
			/// 构造函数
			/// </summary>
			/// <param name="ch">初始化当前对象的FdChar字符</param>
			/// <param name="pMultiByteStr">初始化当前对象的多字节字符串</param>
			/// <param name="pUnicodeStr">初始化当前对象的Unicode字符串</param>
			/// <param name="str">初始化当前对象的FdMultiByteString对象</param>
			/// <param name="wstr">初始化当前对象的FdUnicodeString对象</param>
			/// <returns></returns>
			FdMultiByteString();
			FdMultiByteString( const CHAR &ch);
			FdMultiByteString( const FdChar  &ch);
			FdMultiByteString( const CHAR  *pMultiByteStr);
			FdMultiByteString( const WCHAR *pUnicodeStr);
			FdMultiByteString(const FdMultiByteString &str);
			FdMultiByteString(const FdUnicodeString &wstr);
			FdMultiByteString(const FdGbkString& strGBK);
			virtual ~FdMultiByteString();
			/// <summary>
			/// 获取当前字符串对象的长度
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回字符的个数</returns>
			size_t    getLength() const;
			size_t    length() const
			{
				return getLength();
			}
			/// <summary>
			/// 获取当前字符串对象的内存长度
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			size_t    size() const
			{
				return m_strDataBuffer.size();
			}
			/// <summary>
			/// 重新指定字符串的长度,会重置字符串
			/// </summary>
			/// <param name="len">字符个数</param>
			/// <param name=""></param>
			/// <returns></returns>
			void      resize(size_t len)
			{
				m_strDataBuffer.resize(len);
			}

			/// <summary>
			/// 保留给定长度的内存
			/// </summary>
			/// <param name="len">字符个数</param>
			/// <param name=""></param>
			/// <returns></returns>
			void  reserve(size_t len)
			{
				m_strDataBuffer.reserve(len);
			}
			FdMultiByteString &assign(const_iterator first, const_iterator last)
			{
				m_strDataBuffer.assign(first, last);
				return *this;
			}

			FdMultiByteString &assign(const CHAR *ptr, size_type offset, size_type count)
			{
				m_strDataBuffer.assign(ptr, offset, count);
				return *this;
			}
			FdMultiByteString &assign(size_type count, CHAR ch)
			{
				m_strDataBuffer.assign(count, ch);
				return *this;
			}
			FdMultiByteString &assign(const CHAR *ptr)
			{
				m_strDataBuffer.assign(ptr);
				return *this;
			}
			FdMultiByteString &assign(const CHAR *ptr, size_type count)
			{
				m_strDataBuffer.assign(ptr, count);
				return *this;
			}
			inline FD_Kernel_Export friend std::basic_stringstream<CHAR>& operator <<
				( std::basic_stringstream<CHAR>& stm, const FdMultiByteString &str )
			{
				stm << str.m_strDataBuffer;
				return stm;
			}
			inline FD_Kernel_Export friend std::basic_stringstream<CHAR>& operator >>
				( std::basic_stringstream<CHAR>& stm, FdMultiByteString &str )
			{
				stm >> str.m_strDataBuffer;
				return stm;
			}
			inline FD_Kernel_Export friend FdMultiByteString &operator <<
				( const CHAR *stm, FdMultiByteString &str )
			{
				str = stm + str;
				return str;
			}

			/// <summary>
			/// 重载(size_t)操作符,用于hash表
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回字符串作为hash键值的键值长度</returns>
			operator size_t()const
			{
				size_t ret = 0;
				for(const_iterator it = m_strDataBuffer.begin(); it != m_strDataBuffer.end(); ++it )
					ret = 5 * ret + *it;
				return ret;

			}
			/// <summary>
			/// 重载流输出运算符
			/// </summary>
			/// <param name="o">输出流</param>
			/// <param name="str">字符串</param>
			/// <returns></returns>
			inline FD_Kernel_Export friend std::ostream &operator <<
				(  std::ostream &o,  const FdMultiByteString &str )
			{
				o << str.m_strDataBuffer;
				return o;
			}
			/// <summary>
			/// 返回字符串数据块的指针
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			const CHAR *data() const
			{
				return m_strDataBuffer.data();
			}
			/// <summary>
			/// 获取当前已分配的缓冲区长度
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回缓冲区的长度</returns>
			size_t    getAllocLength() const;
			/// <summary>
			/// 判断当前字符串对象是否为空
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>如果字符串为空返回true，否则返回false</returns>
			bool  isEmpty()   const;
			bool  empty()   const
			{
				return isEmpty();
			}
			/// <summary>
			/// 清空当前字符串
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			void  clear();
			/// <summary>
			/// 返回字符串指针
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			const CHAR *c_str() const
			{
				return m_strDataBuffer.c_str();
			}
			/// <summary>
			/// 释放掉已经分配但未使用的缓冲内存以减小内存占用单位
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns></returns>
			void  freeExtraMem();
			/// <summary>
			/// 获取指定位置的字符
			/// </summary>
			/// <param name="nIndex">所要获取的字符的位置</param>
			/// <returns>返回指定位置的字符</returns>
			FdChar getAt( size_t nIndex) const;
			CHAR at( size_t nIndex) const
			{
				return m_strDataBuffer[nIndex];
			}
			/// <summary>
			/// 直接获取当前字符串对象的缓冲区，const CHAR*形式
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回const CHAR*形式的缓冲区指针</returns>
			const CHAR   *getString() const;
			/// <summary>
			/// 直接获取当前字符串对象的缓冲区，CHAR*形式
			/// </summary>
			/// <param name="nMinBufferLengthInChars">最小缓冲区长度</param>
			/// <returns>返回CHAR*形式的缓冲区指针</returns>
			CHAR  *getBuffer( size_t nMinBufferLengthInChars);
			CHAR  *getBuffer();
			/// <summary>
			/// 生成缓冲区,并将内容复制到该缓冲区
			/// 该缓冲区由调用者释放
			/// </summary>
			/// <returns>返回CHAR*形式的缓冲区指针</returns>
			CHAR *makeBuffer() const;
			/// <summary>
			/// 删除指定位置指定数量的字符
			/// </summary>
			/// <param name="nBeginIndex">删除的起始位置</param>
			/// <param name="nCount">删除字符的数量</param>
			/// <returns>返回实际删除字符的个数</returns>
			size_t deleteAt( size_t nBeginIndex,  size_t nCount);
			size_t deleteAt( size_t nBeginIndex);
			/// <summary>
			/// 设置指定位置的字符
			/// </summary>
			/// <param name="nIndex">删除的起始位置</param>
			/// <param name="ch">设置的字符值</param>
			/// <returns></returns>
			void setAt( size_t nIndex,  const FdChar &ch);
			/// <summary>
			/// 设置当前对象的字符串值
			/// </summary>
			/// <param name="pMultiByteStr">指定的多字节字符串值</param>
			/// <param name="pUnicodeStr">指定的Unicode字符串值</param>
			/// <returns></returns>
			void setString( const CHAR  *pMultiByteStr);
			void setString( const WCHAR *pUnicodeStr);
			/// <summary>
			/// 在当前字符串对象末尾追加数据
			/// </summary>
			/// <param name="ch">追加FdChar字符</param>
			/// <param name="pMultiByteStr">追加char*的字符串</param>
			/// <param name="pUnicodeStr">追加Unicode字符串</param>
			/// <param name="nCount">从缓冲区中指定的字符数目</param>
			/// <param name="strMultiByte">char*的字符串</param>
			/// <param name="strUnicode">Unicode的字符串</param>
			/// <returns>返回追加后的当前字符串对象的引用</returns>
			FdMultiByteString  &append( const FdChar  &ch);
			FdMultiByteString  &append( const CHAR  *pMultiByteStr);
			FdMultiByteString  &append( const WCHAR *pUnicodeStr);
			FdMultiByteString  &append( const CHAR  *pMultiByteStr,  size_t nCount);
			FdMultiByteString  &append( const WCHAR *pUnicodeStr,  size_t nCount);
			FdMultiByteString  &append( const FdMultiByteString  &strMultiByte);
			FdMultiByteString  &append( const FdUnicodeString    &strUnicode);
			FdMultiByteString  &append( const CHAR ch);
			FdMultiByteString &append(const std::string& str, size_type _Roff, size_type _Count);
			FdMultiByteString &append(const FdMultiByteString& str, size_type _Roff, size_type _Count);
			/// <summary>
			/// 在当前字符串对象的指定位置插入数据
			/// </summary>
			/// <param name="nIndexOfPos">插入字符串的位置</param>
			/// <param name="ch">插入FdChar字符</param>
			/// <param name="pMultiByteStr">插入char*的字符串</param>
			/// <param name="pUnicodeStr">插入Unicode字符串</param>
			/// <returns>返回插入新数据后的当前字符串对象的引用</returns>
			FdMultiByteString  &insert( size_t nIndexOfPos,  const FdChar  &ch);
			FdMultiByteString  &insert( size_t nIndexOfPos,  const CHAR  *pMultiByteStr);
			FdMultiByteString  &insert( size_t nIndexOfPos,  const WCHAR *pUnicodeStr);
			/// <summary>
			/// 格式化当前字符串
			/// </summary>
			/// <param name="pFormatStr">格式化的描述字符串</param>
			/// <param name="pFormatWStr">格式化的描述字符串</param>
			/// <returns>返回格式化完成后的当前字符串对象的引用</returns>
			FdMultiByteString  &format( const CHAR  *pFormatStr,  ...);
			FdMultiByteString  &format( const WCHAR *pFormatWStr,  ...);
			/// <summary>
			/// 生成指定的格式化字符串并追加到当前字符串末尾
			/// </summary>
			/// <param name="pFormatStr">格式化的描述字符串</param>
			/// <param name="pFormatWStr">格式化的描述字符串</param>
			/// <returns>返回格式化完成后的当前字符串对象的引用</returns>
			FdMultiByteString  &formatAppend( const CHAR  *pFormatStr, ...);
			FdMultiByteString  &formatAppend( const WCHAR *pFormatWStr, ...);
			/// <summary>
			/// 查找指定字符或字符串在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的子串</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找</param>
			/// <param name="bIsBeginFromLeft">指定查找方向, true表示从左往右查找，false表示从右往左查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   find( const FdChar  &ch,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find( const CHAR  *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find( const WCHAR *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			/// <summary>
			/// 查找指定字符或字符串在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的子串</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找,-1则表示从最后一个字符开始查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   rfind( const FdChar  &ch,  size_t nStartIndex = npos) const;
			INT32   rfind( const CHAR  *pSubStr,  size_t nStartIndex = npos) const;
			INT32   rfind( const WCHAR *pSubStr,  size_t nStartIndex = npos) const;

			/// <summary>
			/// 查找单个字符或字符串中任一字符首次出现在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的字符集</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找</param>
			/// <param name="bIsBeginFromLeft">指定查找方向, true表示从左往右查找，false表示从右往左查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   find_first_of( const FdChar  &ch,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find_first_of( const CHAR  *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find_first_of( const WCHAR *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			/// <summary>
			/// 查找单个字符或字符串中任一字符首次未出现在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的字符集</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找</param>
			/// <param name="bIsBeginFromLeft">指定查找方向, true表示从左往右查找，false表示从右往左查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   find_first_not_of( const FdChar  &ch,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find_first_not_of( const CHAR  *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			INT32   find_first_not_of( const WCHAR *pSubStr,  size_t nStartIndex = 0,  bool bIsBeginFromLeft = true) const;
			/// <summary>
			/// 查找单个字符或字符串中任一字符最后一次出现在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的字符集</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找,-1表示从最后位置查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   find_last_of( const FdChar  &ch,  size_t nStartIndex = npos) const;
			INT32   find_last_of( const CHAR  *pSubStr,  size_t nStartIndex = npos) const;
			INT32   find_last_of( const WCHAR *pSubStr,  size_t nStartIndex = npos) const;
			/// <summary>
			/// 查找单个字符或字符串中任一字符最后一次未出现在当前对象中的位置
			/// </summary>
			/// <param name="ch">要查找的字符</param>
			/// <param name="pSubStr">要查找的字符集</param>
			/// <param name="nStartIndex">查找的起始位置, 0表示从字符串首字符开始查找,-1表示从最后位置查找</param>
			/// <returns>找到查找的字符或字符串，返回其所在位置(首字母的位置序号为0，其他的以此类推)，如果未找到则返回-1</returns>
			INT32   find_last_not_of( const FdChar  &ch,  size_t nStartIndex = npos) const;
			INT32   find_last_not_of( const CHAR  *pSubStr,  size_t nStartIndex = npos) const;
			INT32   find_last_not_of( const WCHAR *pSubStr,  size_t nStartIndex = npos) const;

			/// <summary>
			/// 查找指定字符或字符串，并使用指定的字符或字符进行替换
			/// </summary>
			/// <param name="chOld">要查找的字符</param>
			/// <param name="chNew">查找成功后替换的字符</param>
			/// <param name="pStrOld">要查找的字符串</param>
			/// <param name="pStrNew">查找成功后替换的字符串</param>
			/// <param name="pos">起始位置</param>
			/// <returns>返回替换发生的次数</returns>
			size_t   replace( const FdChar  &chOld,  const FdChar &chNew);
			size_t   replace( const CHAR  *pStrOld,  const CHAR *pStrNew);
			size_t   replace( const WCHAR  *pStrOld,  const WCHAR *pStrNew);



			/// <summary>
			/// 将当前字符串中的字符进行反序处理
			/// </summary>
			/// <param name=""></param>
			/// <returns></returns>
			void reverse();
			/// <summary>
			/// 从当前对象中剔除所有指定的字符
			/// </summary>
			/// <param name="ch">要剔除的字符</param>
			/// <param name="pCharSet">要剔除的字符集合，字符串中指定的每个字符都将被剔除</param>
			/// <returns>返回剔除的字符数目</returns>
			size_t   trim( const FdChar &ch);
			size_t   trim( const CHAR *pCharSet);
			size_t   trim( const WCHAR *pCharSet);
			/// <summary>
			/// 从当前对象左端开始剔除指定的字符，直到遇到非剔除字符为止
			/// </summary>
			/// <param name="ch">要剔除的字符</param>
			/// <param name="pCharSet">要剔除的字符集合，字符串中指定的每个字符都将被剔除</param>
			/// <returns>返回剔除的字符数目</returns>
			size_t   trimLeft( const FdChar &ch);
			size_t   trimLeft( const CHAR *pCharSet);
			size_t   trimLeft( const WCHAR *pCharSet);
			/// <summary>
			/// 从当前对象右端开始剔除指定的字符，直到遇到非剔除字符为止
			/// </summary>
			/// <param name="ch">要剔除的字符</param>
			/// <param name="pCharSet">要剔除的字符集合，字符串中指定的每个字符都将被剔除</param>
			/// <returns>返回剔除的字符数目</returns>
			size_t   trimRight( const FdChar &ch);
			size_t   trimRight( const CHAR *pCharSet);
			size_t   trimRight( const WCHAR *pCharSet);
			/// <summary>
			/// 使用指定的分隔符，将当前对象折分成若干子串
			/// </summary>
			/// <param name="chToken">分隔字符</param>
			/// <param name="pTokens">分隔字符集，该串中的每个字符都将作为分隔字符</param>
			/// <param name="vtSubStrings">存储拆分后的子串的list</param>
			/// <returns>返回拆分的子串数量</returns>
			size_t   tokenize( const FdChar &chToken,  std::vector<FdMultiByteString> &vtSubStrings) const;
			size_t   tokenize( const CHAR *pTokens,  std::vector<FdMultiByteString> &vtSubStrings) const ;
			size_t   tokenize( const WCHAR *pTokens,  std::vector<FdMultiByteString> &vtSubStrings) const;
			/// <summary>
			/// 从当前操作系统中获取指定环境变量，并将其存储在当前对象中
			/// </summary>
			/// <param name="pEnvVarName">环境变量名称</param>
			/// <returns>获取环境变量成功返回true，否则返回false</returns>
			bool getEnvironmentVariable( const CHAR  *pEnvVarName);
			bool getEnvironmentVariable( const WCHAR *pEnvVarName);

			/// <summary>
			/// 从当前操作系统中获取环境变量，并将其存储在当前对象中
			/// </summary>
			/// <returns>获取环境变量成功返回true，否则返回false</returns>
			bool getGlobeEnvironmentVariable();

			/// <summary>
			/// 取当前对象的子串
			/// </summary>
			/// <param name="nStartIndex">要获取的子串的起始位置</param>
			/// <param name="nCount">子串的长度</param>
			/// <returns>返回子串对象</returns>
			FdMultiByteString   subString( size_t nStartIndex,  size_t nCount) const;
			FdMultiByteString   substr( size_t nStartIndex,  size_t nCount = 0) const
			{
				if(nCount == 0)
					nCount = length() - nStartIndex;
				return subString(nStartIndex, nCount);
			}
			/// <summary>
			/// 将当前对象的字符串变成小写
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回改变后的当前对象</returns>
			FdMultiByteString  &makeLower();
			/// <summary>
			/// 将当前对象转化为小写字符串返回，但当前对象不改变
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回转化为小写的字符串对象</returns>
			FdMultiByteString   toLower() const;
			/// <summary>
			/// 将当前对象的字符串变成大写
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回改变后的当前对象</returns>
			FdMultiByteString  &makeUpper();
			/// <summary>
			/// 将当前对象转化为大写字符串返回，但当前对象不改变
			/// </summary>
			/// <param name=""></param>
			/// <param name=""></param>
			/// <returns>返回转化为大写的字符串对象</returns>
			FdMultiByteString   toUpper() const;
			/// <summary>
			/// 判断当前对象是否是以某个指定的字符串为头
			/// </summary>
			/// <param name="str">字符串对象</param>
			/// <returns>如果当前对象是以str为头返回true，否则返回false</returns>
			bool isHeadString( const FdMultiByteString &str) const;
			/// <summary>
			/// 判断当前对象是否是以某个指定的字符串为尾
			/// </summary>
			/// <param name="str">字符串对象</param>
			/// <returns>如果当前对象是以str为尾返回true，否则返回false</returns>
			bool isTailString( const FdMultiByteString &str) const;
			/// <summary>
			/// 将当前字符串转换成double
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的double值</returns>
			double   getReal64() const;
			/// <summary>
			/// 将当前字符串转换成float
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的float值</returns>
			float   getReal32() const;
			/// <summary>
			/// 将当前字符串转换成INT64
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的INT64值</returns>
			INT64    getInt64()  const;
			/// <summary>
			/// 将当前字符串转换成UINT64
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的UINT64值</returns>
			UINT64   getUint64() const;
			/// <summary>
			/// 将当前字符串转换成int32
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的int32值</returns>
			INT32    getInt32()  const;
			/// <summary>
			/// 将当前字符串转换成uint32
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回转换后的uint32值</returns>
			uint32   getUint32() const;
			/// <summary>
			/// 赋值操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <param name="strMultiByte">多字节字符串对象</param>
			/// <param name="strUnicode">Unicode字符串对象</param>
			/// <returns>返回当前对象的引用</returns>
			FdMultiByteString  &operator=( const FdChar  &ch);
			FdMultiByteString  &operator=( const char  &c);
			FdMultiByteString  &operator=( const CHAR  *pMultiByteStr);
			FdMultiByteString  &operator=( const WCHAR *pUnicodeStr);
			FdMultiByteString  &operator=( const FdMultiByteString &strMultiByte);
			FdMultiByteString  &operator=( const FdUnicodeString &strUnicode);
			FdMultiByteString  &operator=( const std::string    &strMultiByte);
			FdMultiByteString  &operator=( const wchar_string   &strUnicode);
			FdMultiByteString  &operator=( const FdGbkString& strGBK);
			/// <summary>
			/// +号操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>返回相加后的FdMultiByteString对象</returns>
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdMultiByteString &strMultiByteL,  const FdMultiByteString &strMultiByteR);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdMultiByteString &strMultiByte,  const FdUnicodeString strUnicode);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdChar  &ch,  const FdMultiByteString &strMultiByte);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdMultiByteString &strMultiByte,  const FdChar  &ch);
			friend FD_Kernel_Export FdMultiByteString  operator+( const CHAR *pMultiByteStr,  const FdMultiByteString &strMultiByte);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdMultiByteString &strMultiByte,  const CHAR *pMultiByteStr);
			friend FD_Kernel_Export FdMultiByteString  operator+( const WCHAR *pUnicodeStr,  const FdMultiByteString &strMultiByte);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdMultiByteString &strMultiByte,  const WCHAR *pUnicodeStr);
			friend FD_Kernel_Export FdMultiByteString  operator+( const CHAR *pMultiByteStr,  const FdChar  &ch);
			friend FD_Kernel_Export FdMultiByteString  operator+( const FdChar  &ch,  const CHAR *pMultiByteStr);
			/// <summary>
			/// +=运算符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>返回相加后的FdMultiByteString对象</returns>
			FdMultiByteString  &operator+=( const FdChar  &ch);
			FdMultiByteString  &operator+=( const CHAR  *pMultiByteStr);
			FdMultiByteString  &operator+=( const WCHAR *pUnicodeStr);
			FdMultiByteString  &operator+=( const FdMultiByteString &strMultiByte);
			FdMultiByteString  &operator+=( const FdUnicodeString &strUnicode);
			FdMultiByteString  &operator+=( const CHAR &ch);
			/// <summary>
			/// 等于操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>如果两边相等返回true，否则返回false</returns>
			bool operator==( const FdChar  &ch) const;
			bool operator==( const CHAR  *pMultiByteStr) const;
			bool operator==( const WCHAR *pUnicodeStr) const;
			bool operator==( const FdMultiByteString &strMultiByte) const;
			bool operator==( const FdUnicodeString &strUnicode) const;
			friend  FD_Kernel_Export bool    operator==( const CHAR  *pMultiByteStr,  const FdMultiByteString &strMultiByte);
			friend  FD_Kernel_Export bool    operator==( const WCHAR *pUnicodeStr,  const FdMultiByteString &strMultiByte);
			/// <summary>
			/// 不等于操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>如果两边不相等返回true，否则返回false</returns>
			bool operator!=( const FdChar  &ch) const;
			bool operator!=( const CHAR  *pMultiByteStr) const;
			bool operator!=( const WCHAR *pUnicodeStr) const;
			bool operator!=( const FdMultiByteString &strMultiByte) const;
			bool operator!=( const FdUnicodeString &strUnicode) const;
			friend  FD_Kernel_Export bool    operator!=( const CHAR  *pMultiByteStr,  const FdMultiByteString &strMultiByte);
			friend  FD_Kernel_Export bool    operator!=( const WCHAR *pUnicodeStr,  const FdMultiByteString &strMultiByte);
			/// <summary>
			/// 小于操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>如果左边小于右边返回true，否则返回false</returns>
			bool operator<( const FdChar  &ch) const;
			bool operator<( const CHAR  *pMultiByteStr) const;
			bool operator<( const WCHAR *pUnicodeStr) const;
			bool operator<( const FdMultiByteString &strMultiByte) const;
			bool operator<( const FdUnicodeString &strUnicode) const;
			friend  FD_Kernel_Export bool    operator<( const CHAR  *pMultiByteStr,  const FdMultiByteString &strMultiByte);
			friend  FD_Kernel_Export bool    operator<( const WCHAR *pUnicodeStr,  const FdMultiByteString &strMultiByte);
			/// <summary>
			/// 大于操作符重载
			/// </summary>
			/// <param name="ch">单个FdChar字符</param>
			/// <param name="strMultiByte">FdMultiByteString对象</param>
			/// <param name="strUnicode">FdUnicodeString对象</param>
			/// <param name="pMultiByteStr">CHAR型字符串</param>
			/// <param name="pUnicodeStr">WCHAR型字符串</param>
			/// <returns>如果左边大于右边返回true，否则返回false</returns>
			bool operator>( const FdChar  &ch) const;
			bool operator>( const CHAR  *pMultiByteStr) const;
			bool operator>( const WCHAR *pUnicodeStr) const;
			bool operator>( const FdMultiByteString &strMultiByte) const;
			bool operator>( const FdUnicodeString &strUnicode) const;
			friend  FD_Kernel_Export bool    operator>( const CHAR  *pMultiByteStr,  const FdMultiByteString &strMultiByte);
			friend  FD_Kernel_Export bool    operator>( const WCHAR *pUnicodeStr,  const FdMultiByteString &strMultiByte);
			/// <summary>
			/// 数组操作符重载
			/// </summary>
			/// <param name="nIndex">要访问的字符的位置，0表示首字母</param>
			/// <returns>返回CHAR字符</returns>

#ifdef __OS_WIN64__
			CHAR    &operator[]( size_t  iIndex);
			const CHAR &operator[]( size_t  iIndex) const;
			//				CHAR    &operator[]( size_t nIndex);
			//				const CHAR &operator[]( size_t nIndex) const;

			//				CHAR &operator[]( size_t nIndex);
			//                const CHAR &operator[]( size_t nIndex) const;
#elif defined(__x86_64)
			CHAR    &operator[]( size_t  iIndex);
			const CHAR &operator[]( size_t  iIndex) const;
#else
			CHAR    &operator[]( INT32  iIndex);
			const CHAR &operator[]( INT32  iIndex) const;
			CHAR    &operator[]( uint32 nIndex);
			const CHAR &operator[]( uint32 nIndex) const;
#endif
			/// <summary>
			/// 类似于getString，直接访问数据区
			/// </summary>
			/// <param name=""></param>
			/// <returns>返回const CHAR*的数据缓冲区</returns>
			operator const CHAR*() const;
			operator   CHAR*();
			FdMultiByteString &operator<<( const CHAR  *pStr);
			FdMultiByteString &operator<<( const WCHAR *pWStr);
			FdMultiByteString &operator<<( const INT8  iNumber);
			FdMultiByteString &operator<<( const UINT8 nNumber);
			FdMultiByteString &operator<<( const INT16  iNumber);
			FdMultiByteString &operator<<( const UINT16 nNumber);
			FdMultiByteString &operator<<( const INT32  iNumber);
			FdMultiByteString &operator<<( const uint32 nNumber);
			FdMultiByteString &operator<<( const INT64  iNumber);
			FdMultiByteString &operator<<( const UINT64 nNumber);
			FdMultiByteString &operator<<( const float fNumber);
			FdMultiByteString &operator<<( const double dbNumber);
			FdMultiByteString &operator<<( const void  *pointer);
			FdMultiByteString &operator<<( const FdMultiByteString &str);
			FdMultiByteString &operator<<( const FdUnicodeString &wstr);
			/// <summary>
			/// 将给定的字符串转换成double
			/// </summary>
			/// <param name="pNumberString">给定的字符串</param>
			/// <returns>返回转换后的double值，当字符串无法转换为double时，将返回0</returns>
			static   double    stringToReal64( const CHAR *pNumberString);

		protected:
			///字符数据存储对象
			std::string    m_strDataBuffer;
			///字符编码器
			static ITextCodec    *m_pTextCodec;
		};
	}
}

#endif
